//
//  RACCommandVC.m
//  ReactiveCocoa
//
//  Created by apple on 2017/9/11.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "RACCommandVC.h"
#import <ReactiveObjC/ReactiveObjC.h>

@interface RACCommandVC ()

@end

@implementation RACCommandVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    RACCommand *command = [[RACCommand alloc] initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
       
        return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
           
            //接收到传入的数据后，发送信号数据
            
            [subscriber sendNext:@"发送的数据"];
            
            return nil;
        }];
    }];
    
    //execute 传入某些东西
    RACSignal *signal = [command execute:@"传入的数据"];
    
    //订阅信号
    [signal subscribeNext:^(id  _Nullable x) {
       
        NSLog(@"%@",x);
    }];
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
